package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Elitist;
import com.ruoyi.system.service.IElitistService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 百千万人才Controller
 * 
 * @author wei&wu
 * @date 2024-05-25
 */
@RestController
@RequestMapping("/system/elitist")
public class ElitistController extends BaseController
{
    @Autowired
    private IElitistService elitistService;

    /**
     * 查询百千万人才列表
     */
    @PreAuthorize("@ss.hasPermi('system:elitist:list')")
    @GetMapping("/list")
    public TableDataInfo list(Elitist elitist)
    {
        startPage();
        List<Elitist> list = elitistService.selectElitistList(elitist);
        return getDataTable(list);
    }

    /**
     * 导出百千万人才列表
     */
    @PreAuthorize("@ss.hasPermi('system:elitist:export')")
    @Log(title = "百千万人才", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Elitist elitist)
    {
        List<Elitist> list = elitistService.selectElitistList(elitist);
        ExcelUtil<Elitist> util = new ExcelUtil<Elitist>(Elitist.class);
        util.exportExcel(response, list, "百千万人才数据");
    }

    /**
     * 获取百千万人才详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:elitist:query')")
    @GetMapping(value = "/{employeeId}")
    public AjaxResult getInfo(@PathVariable("employeeId") Long employeeId)
    {
        return success(elitistService.selectElitistByEmployeeId(employeeId));
    }

    /**
     * 新增百千万人才
     */
    @PreAuthorize("@ss.hasPermi('system:elitist:add')")
    @Log(title = "百千万人才", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Elitist elitist)
    {
        return toAjax(elitistService.insertElitist(elitist));
    }

    /**
     * 修改百千万人才
     */
    @PreAuthorize("@ss.hasPermi('system:elitist:edit')")
    @Log(title = "百千万人才", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Elitist elitist)
    {
        return toAjax(elitistService.updateElitist(elitist));
    }

    /**
     * 删除百千万人才
     */
    @PreAuthorize("@ss.hasPermi('system:elitist:remove')")
    @Log(title = "百千万人才", businessType = BusinessType.DELETE)
	@DeleteMapping("/{employeeIds}")
    public AjaxResult remove(@PathVariable Long[] employeeIds)
    {
        return toAjax(elitistService.deleteElitistByEmployeeIds(employeeIds));
    }
}
